<script type="text/javascript" language="javascript" charset="utf-8">
$(".header-con li a").removeClass("open-menu");
$(".header-con li #employee").addClass("open-menu");
</script>
<div class="boxed clearfix">
  <div class="common-tit">
    <h2>添加员工</h2>
    <span>人资管理 > 员工列表 > 员工详情</span>
    <div class="emp-gbtn">
      <a href="">离职</a >
      <%=link_to '编辑', edit_admin_employee_path(@employee) %>
    </div>
  </div>
  <div class="ad-box">
    <div class="basic">
      <h3>
        <span>基本信息</span>
      </h3>
      <div class="staff-info">
        <div class="de-camera">
          <div class="ca">
            <% if @employee.avatar.present? %>
              <%= image_tag("#{@employee.avatar_url}", size: "150x166", alt: "头像" ,id: "employee_avatar_img")%>
            <% else %>
              <%= image_tag("/avatar.png", size: "150x166", alt: "头像" ,id: "employee_avatar_img")%>
            <% end %>
          </div>
        </div>
        <ul class="de-box">
          <li>
            <span>姓名:</span>
            <em><%= @employee.name %></em>
          </li>
          <li>
            <span>别名:</span>
            <em><%= @employee.alias_name %></em>
          </li>
          <li>
            <span>性别:</span>
            <em><%= @employee.sex %></em>
          </li>
          <li>
            <span>微信号:</span>
            <em><%= @employee.weixin %></em>
          </li>
          <li>
            <span>手机号:</span>
            <em><%= @employee.mobile %></em>
          </li>
          <li>
            <span>出生日期:</span>
            <em><%= @employee.birthday.to_s %></em>
          </li>
          <li>
            <span>紧急联系人:</span>
            <em><%= @employee.emergency_contact %></em>
          </li>
          <li>
            <span>紧急联系人电话:</span>
            <em><%= @employee.emergency_mobile %></em>
          </li>
          <li class="de-a">
            <span>联系地址:</span>
            <em><%= @employee.address %></em>
          </li>
          <li class="de-a">
            <span>备注:</span>
            <em><%= @employee.remark %></em>
          </li>
        </ul>
      </div>
    </div>
    <div class="st-pos">
      <h3>
        <span>其他信息</span>
      </h3>
      <div class="pos-b">
        <ul class="de-other clearfix">
          <li>
            <span>登陆账号:</span>
            <em><%=@employee.user.mobile %></em>
          </li>
          <li>
            <span>入职日期:</span>
            <em><%= @employee.joined_at.strftime("%Y-%m-%d") %></em>
          </li>
          <li>
            <span>离职日期:</span>
            <em><%= @employee.dismissed_at.try(:to_s, :db) %></em>
          </li>
        </ul>
      </div>
		</div>
		<div class="st-pos">
			<h3>
				<span>职位信息</span>
			</h3>
      <div class="pos-b stp-b">
        <div class="pexh-box">
          <% @employee_of_studio_groups = @employee_of_studios.group_by {|s| s.position_id} %>
          <% @employee_of_studio_groups.each do |position_id,emp_of_studios| %>
            <% emp_of_studio = emp_of_studios.first %>
            <ul class="pos-exh clearfix">
              <li>
                <span>部门:</span>
                <em><%= emp_of_studio.department_configuration.department_name %></em>
              </li>
              <li>
                <span>职位:</span>
                <em><%= emp_of_studio.position_name %></em>
              </li>
              <li>
                <span>所属分店:</span>
                <% if emp_of_studios.size == 1 %>
                  <em><%= emp_of_studio.studio.name %></em>
                <% elsif emp_of_studios.size > 1 %>
                  <em><%= emp_of_studios.map {|es| es.studio.name}.join(', ') %></em>
                <% end %>
              </li>
              <% if emp_of_studio.position_name == '导师' %>
                <li>
                  <span>授课对象:</span>
                  <em><%= emp_of_studio.teacher.try :age_group %></em>
                </li>
                <li>
                  <span>舞种:</span>
                  <em><%= emp_of_studio.teacher.try :dance_type %></em>
                </li>
                <li>
                  <span>导师等级:</span>
                  <em><%= emp_of_studio.teacher.try :teacher_level %></em>
                </li>
              <% end %>
            </ul>
          <% end %>
				</div>
			</div>
		</div>
    <div class="st-pos">
      <h3>
        <span>薪资信息</span>
      </h3>
      <div class="pos-salary">
        <div class="sel-t">
          <strong>基本工资:</strong>
          <% if @basic_salary %>
            <em><%= @basic_salary.amount %>元</em>
          <% else %>
            -
          <% end %>
        </div>
        <div class="sel-con">
          <strong>薪资提成:</strong>
          <div class="sel-d">

            <% if @product_director_salaries.present? %>
              <div class="sel-b">
                <h5>产品总监:</h5>
                <div class="commission-box">
                  <ul>
                    <% @product_director_salaries.each do |salary| %>
                    <li>
                      <span><%= salary.range_min %>-<%= salary.range_max %>元阶段提成比例为<%= salary.amount %>%</span>
                    </li>
                  <% end %>
                  </ul>
                </div>
              </div>
            <% end %>

            <% amounts = @teachers.select {|teacher| teacher.amount } %>
            <% if amounts.size > 0 %>
            <div class="sel-b">
              <h5>导师:</h5>
              <div class="commission-box">
                <ul>

                  <% if @course_salary.amount %>
                    <li>
                      <span>课时费用:</span>
                      <em><%= @course_salary.amount %>元/课时</em>
                    </li>
                  <% end %>

                  <% if @fixed_salary %>
                    <li>
                      <span>固定提成:</span>
                      <em><%= @fixed_salary.amount %>元/人</em>
                    </li>
                  <% end %>

                  <% if @staged_salaries.present? %>
                  <li>
                    <span>阶段提成:</span>
                    <div class="sel-tc">
                      <% @staged_salaries.each do |salary| %>
                      <div>
                        <%= salary.range_min %>-<%= salary.range_max %>人阶段提成比例为<%= salary.amount %>元/人
                      </div>
                    <% end %>
                    </div>
                  </li>
                <% end %>


                  <% if @teacher_salaries.present? %>
                  <li>
                    <span>超出指标提成:</span>
                    <div class="sel-tc">
                      <% @teacher_salaries.each do |salary| %>
                      <div>
                        <%= salary.range_min %>-<%= salary.range_max %>元阶段提成比例为<%= salary.amount %>%
                      </div>
                    <% end %>
                    </div>
                  </li>
                <% end %>

                  <% if @private_salary.amount %>
                    <li>
                      <span>私教提成:</span>
                      <em><%= @private_salary.amount %>%</em>
                    </li>
                  <% end %>

                </ul>
              </div>
            </div>
          <% end %>

            <% if @service_director_salaries.present? %>
              <div class="sel-b">
                <h5>运营总监:</h5>
                <div class="commission-box">
                  <ul>
                    <% @service_director_salaries.each do |salary| %>
                    <li>
                      <span><%= salary.range_min %>-<%= salary.range_max %>元阶段提成比例为<%= salary.amount %>%</span>
                    </li>
                  <% end %>
                  </ul>
                </div>
              </div>
            <% end %>

            <% if @service_salaries.present? %>
              <div class="sel-b">
                <h5>服务顾问:</h5>
                <div class="commission-box">
                  <ul>
                    <% @service_salaries.each do |salary| %>
                    <li>
                      <span><%= salary.range_min %>-<%= salary.range_max %>元阶段提成比例为<%= salary.amount %>%</span>
                    </li>
                  <% end %>
                  </ul>
                </div>
              </div>
            <% end %>

            <% if @market_director_salaries.present? %>
              <div class="sel-b">
                <h5>市场总监:</h5>
                <div class="commission-box">
                  <ul>
                    <% @market_director_salaries.each do |salary| %>
                    <li>
                      <span><%= salary.range_min %>-<%= salary.range_max %>人阶段提成比例为<%= salary.amount %>%</span>
                    </li>
                  <% end %>
                  </ul>
                </div>
              </div>
            <% end %>

            <% if @market_salaries.present? %>
              <div class="sel-b">
                <h5>市场专员:</h5>
                <div class="commission-box">
                  <ul>
                    <% @market_salaries.each do |salary| %>
                    <li>
                      <span><%= salary.range_min %>-<%= salary.range_max %>人阶段提成比例为<%= salary.amount %>%</span>
                    </li>
                  <% end %>
                  </ul>
                </div>
              </div>
            <% end %>

          </div>
        </div>

        <div class="sel-c">
          <strong>福利补助:</strong>

          <% if @welfares.present? %>
            <ul>
              <% @welfares.each do |welfare| %>
                <li>
                  <span><%= welfare.salary_type[5..-1] %>:</span>
                  <em><%= welfare.amount %>元/月</em>
                </li>
              <% end %>
            </ul>
          <% else %>
              -
          <% end %>

        </div>
      </div>
    </div>
  </div>
</div>

<script src="/assets/js/common-list.js"></script>
<script>
$(function(){
  $('.date-input').date_input();
});
</script>
